var wailianStaticMethod = function(url,key,params,pushstatus,backstatus) {  
    var obj = new Object();
    var userAgent = navigator.userAgent.toLowerCase();
    obj.getSystem = function(){
        if (userAgent.search("windows nt") != -1) {
            pvendor = 4;
        } else if (userAgent.search("iphone") != -1) {
            pvendor = 2;
        } else if (userAgent.search("ipad") != -1) {
            pvendor = 3;
        } else if (userAgent.search("android") != -1) {
            pvendor = 1;
        } else if (userAgent.search("macintosh") != -1) {
            pvendor = 5;
        } else {
            pvendor = 0;
        }
        return pvendor;
    }
    obj.getBrowser = function() {
        if (userAgent.search('jssdk') != -1 || userAgent.search('aweme') != -1 || userAgent.search('bytelocale') != -1 || userAgent.search('bytedancewebview') != -1) {
            // 头条系
            if (userAgent.search('douyin_lite') != -1 || userAgent.search('aweme_lite') != -1) {
                // 抖音极速版
                browser = 27;
            } else if (userAgent.search('aweme_hotsoon') != -1 || userAgent.search('live_stream') != -1) {
                // 抖音火山版
                browser = 28;
            } else if (userAgent.search('newsarticle') != -1) {
                if (userAgent.search('newslite') != -1) {
                    // 今日头条极速版
                    browser = 30;
                } else {
                    // 今日头条
                    browser = 29;
                }
            } else if (userAgent.search('videoarticle') != -1) {
                // 西瓜视频
                browser = 31;
            } else {
                // 抖音
                browser = 26;
            }
        } else if (userAgent.search('baiduboxapp') != -1) {
            if (userAgent.search('matrixstyle')  != -1) {
                // 百度极速版
                browser = 33;
            } else {
                // 百度
                browser = 9;
            }
        } else if(userAgent.search('kwai') != -1){
            browser = 36;
        } else if(userAgent.search('wxwork') != -1){
            browser = 37;
        } else if(userAgent.search('macwechat') != -1){
            browser = 38;
        } else if(userAgent.search('windowswechat') != -1){
            browser = 39;
        } else if(userAgent.search('miniprogram') != -1){
            browser = 40;
        } else if (userAgent.search('tieba') != -1) {
            // 百度贴吧
            browser = 34;
        } else if(userAgent.search('micromessenger') != -1) {
            // 微信浏览器
            browser = 1;
        } else if(userAgent.search('qq/') != -1){
            browser = "2";
        } else if(userAgent.search('vivobrowser') != -1){
            // Vivo浏览器
            browser = "3";
        } else if(userAgent.search('heytapbrowser') != -1){
            // Oppo浏览器
            browser = "4";
        } else if(userAgent.search('huaweibrowser') != -1){
            // 华为浏览器
            browser = "5";
        } else if(userAgent.search('miuibrowser') != -1){
            // 小米浏览器
            browser = "6";
        } else if(userAgent.search('mqqbrowser') != -1){
            // QQ浏览器
            browser = "7";
        } else if(userAgent.search('alipayclient') != -1){
            // 支付宝浏览器
            browser = "8";
        } else if(userAgent.search('weibo') != -1){
            // 微博浏览器
            browser = "10";
        } else if(userAgent.search('iqiyi') != -1){
            // 爱奇艺浏览器
            browser = "11";
        } else if(userAgent.search('miuibrowser') != -1 || userAgent.search('xiaomi') != -1){
            // 小米浏览器
            browser = "12";
        } else if(userAgent.search('bytelocale') != -1 || userAgent.search('bytedancewebview') != -1){
            // 抖音浏览器
            browser = "26";
        } else if(userAgent.search('kdtunion_iting') != -1){
            // 喜马拉雅
            browser = "13";
        } else if(userAgent.search('dingtalk') != -1){
            // 钉钉
            browser = "14";
        } else if(userAgent.search('ucbrowser') != -1){
            // UC浏览器
            browser = "15";
        } else if(userAgent.search('samsungbrowser') != -1){
            // 三星浏览器
            browser = "16";
        } else if(userAgent.search('nokiabrowser') != -1){
            // 诺基亚浏览器
            browser = "17";
        } else if(userAgent.search('opera') != -1){
            // 欧朋
            browser = "18";
        } else if(userAgent.search('firefox') != -1){
            // 火狐
            browser = "19";
        } else if(userAgent.search('zhihu') != -1 || userAgent.search('hihu') != -1){
            // 知乎
            browser = "20";
        } else if(userAgent.search('larkLocale') != -1){
            browser = "21";
        } else if(userAgent.search('iphone') != -1){
            browser = "22";
        } else if(userAgent.search('ipad') != -1){
            browser = "23";
        } else if(userAgent.search('macintosh') != -1){
            browser = "24";
        } else {
            browser = "25";
        }
        return browser;
    }
    obj.getDevice = function(){
        var sUserAgent = navigator.userAgent.toLowerCase();
        var isIphone = userAgent.match(/iphone/i) == "iphone";
        var isHuawei = userAgent.match(/huawei/i) == "huawei";
        var isHonor = userAgent.match(/honor/i) == "honor";
        var isOppo = userAgent.match(/oppo/i) == "oppo";
        var isRealme = userAgent.match(/rmx/i) == "rmx";
        var isOppoR15 = userAgent.match(/pacm00/i) == "pacm00";
        var isVivo = userAgent.match(/vivo/i) == "vivo";
        var isXiaomi = userAgent.match(/mi\s/i) == "mi ";
        var isXiaomi2s = userAgent.match(/mix\s/i) == "mix ";
        var isRedmi = userAgent.match(/redmi/i) == "redmi";
        var isSamsung = userAgent.match(/sm-/i) == "sm-";
        if (isIphone) {
            return 6;
        } else if (isHuawei || isHonor) {
            return 1;
        } else if (isOppo || isOppoR15 || isRealme) {
            return 4;
        } else if (isVivo) {
            return 2;
        } else if (isXiaomi || isRedmi || isXiaomi2s) {
            return 3;
        } else if (isSamsung) {
            return 5;
        } else {
            return 0;
        }
    }
    obj.siteListsIpsStatistic = function(requestparams){
        var current_time = Math.round(new Date().getTime()/1000).toString();
        $.ajax({
            "type": "POST",
            "url": url,
            "data": requestparams,
            success:function(result){
                if (result.status == "success") {
                    localStorage.setItem("statistic_time_"+key,current_time);
                    localStorage.setItem("link_url_"+requestparams.kfid,result.data.link_url);
                    staticBack();
                } else {
                    siteErrorNotice(result.code,"链接访问失败",result.msg);
                }
            },
            error:function(XMLHttpRequest, textStatus){
                prompt("网络异常,请稍后尝试!","danger",3000);
            }
        });
    }
    obj.backJson = function(deviceInfo) {
        const requestparams = Object.assign(params, deviceInfo);
        doyeaBack(requestparams);
    }
    obj.pushApiInfo = function(deviceInfo){
        var current_time = Math.round(new Date().getTime()/1000).toString();
        var review = 1;
        var statistic_time = localStorage.getItem("statistic_time_"+key) || "";
        // 不重复回调
        if (statistic_time != "") return;
        const requestparams = Object.assign(params, deviceInfo);
        $.ajax({
            type: "GET",
            url: "https://apis.map.qq.com/ws/location/v1/ip",
            data: {"key":"DOXBZ-Q43CR-DWZW5-WQCDN-O6XPT-4BBE6","output":"jsonp"},
            dataType: "jsonp",
            success:(res)=>{
                if (res.status == 0) {
                    var province = res.result.ad_info.province;
                    var city = res.result.ad_info.city;
                    var district = res.result.ad_info.district;
                    var ip = res.result.ip;
                } else {
                    var province = "";
                    var city = "";
                    var district = "";
                    var ip = "";
                }
                requestparams["province"] = province;
                requestparams["city"] = city;
                requestparams["district"] = district;
                requestparams["ip"] = ip;
                this.siteListsIpsStatistic(requestparams);
            },
            error:(errormsg)=>{
                siteErrorNotice(1001,"链接异常提醒","网络异常,请检查网络是否正常!");
            },
        });
        return "success";
    }
    obj.device = function() {
        const system = this.getSystem();
        const browser = this.getBrowser();
        const device = this.getDevice();
        if (backstatus) {
            this.backJson({"system": system, "browser": browser, "device": device});
        }
        if (pushstatus) {
            this.pushApiInfo({"system": system, "browser": browser, "device": device});
        }
    }
    return obj;  
}

